﻿
Partial Class WebUserControls_CntlData
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim YearList As New List(Of Integer)
            YearList.Add(Date.Now.Year - 1)
            YearList.Add(Date.Now.Year)
            YearList.Add(Date.Now.Year + 1)
            DDLAnnoInizio.DataSource = YearList
            DDLAnnoInizio.DataBind()

            DDLAnnoFine.DataSource = YearList
            DDLAnnoFine.DataBind()

            DDLAnnoFine.SelectedValue = Date.Now.Year
            DDLAnnoInizio.SelectedValue = Date.Now.Year

            DDLMeseInizio.SelectedValue = Date.Now.Month
            DDLMeseFine.SelectedValue = Date.Now.Month

            DDLGiornoInizio.SelectedValue = Date.Now.Day
            DDLGiornoFine.SelectedValue = Date.Now.Day

            'DDLGiornoInizio.Attributes.Add("onChange", "GiornoInizioChanged()")
            'DDLMeseInizio.Attributes.Add("onChange", "MeseInizioChanged()")
            'DDLAnnoInizio.Attributes.Add("onChange", "AnnoInizioChanged()")
        End If
    End Sub

    Public Property DataInizio As Date
        Set(value As Date)
            Try
                If value = Date.MinValue Then
                    value = Date.Now
                End If
                DDLGiornoInizio.SelectedValue = value.Day
                DDLMeseInizio.SelectedValue = value.Month
                DDLAnnoInizio.SelectedValue = value.Year
            Catch ex As Exception

            End Try

        End Set
        Get
            Return New Date(CInt(DDLAnnoInizio.SelectedValue), CInt(DDLMeseInizio.SelectedValue), CInt(DDLGiornoInizio.SelectedValue))
          
        End Get
    End Property

    Public Property DataFine As Date
        Set(value As Date)
            Try
                If value = Date.MinValue Then
                    value = Date.Now
                End If
                DDLGiornoFine.SelectedValue = value.Day
                DDLMeseFine.SelectedValue = value.Month
                DDLAnnoFine.SelectedValue = value.Year
            Catch ex As Exception

            End Try

        End Set
        Get
            Return New Date(CInt(DDLAnnoFine.SelectedValue), CInt(DDLMeseFine.SelectedValue), CInt(DDLGiornoFine.SelectedValue))
           
        End Get
    End Property

End Class
